package com.qumitech.visualnovel.model.dao.console;

import java.util.*;
import java.text.DecimalFormat;
import com.alibaba.fastjson.JSONObject;

public class UserActDashboardDO {
    private Long id;

    private Date dtdate;

    private Integer actUidNum;

    private Integer actDevNum;

    private Integer remainDay1;

    private Integer remainDay3;

    private Integer remainDay7;

    private Integer payUidNum;

    private Integer payAmount;

    private Integer giftCost;

    private Integer diamondCost;

    private Integer hicoinCost;

    private Integer profit;

    private Date createTime;

    private Date updateTime;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getDtdate() {
        return dtdate;
    }

    public void setDtdate(Date dtdate) {
        this.dtdate = dtdate;
    }

    public Integer getActUidNum() {
        return actUidNum;
    }

    public void setActUidNum(Integer actUidNum) {
        this.actUidNum = actUidNum;
    }

    public Integer getActDevNum() {
        return actDevNum;
    }

    public void setActDevNum(Integer actDevNum) {
        this.actDevNum = actDevNum;
    }

    public Integer getRemainDay1() {
        return remainDay1;
    }

    public void setRemainDay1(Integer remainDay1) {
        this.remainDay1 = remainDay1;
    }

    public Integer getRemainDay3() {
        return remainDay3;
    }

    public void setRemainDay3(Integer remainDay3) {
        this.remainDay3 = remainDay3;
    }

    public Integer getRemainDay7() {
        return remainDay7;
    }

    public void setRemainDay7(Integer remainDay7) {
        this.remainDay7 = remainDay7;
    }

    public Integer getPayUidNum() {
        return payUidNum;
    }

    public void setPayUidNum(Integer payUidNum) {
        this.payUidNum = payUidNum;
    }

    public Integer getPayAmount() {
        return payAmount;
    }

    public void setPayAmount(Integer payAmount) {
        this.payAmount = payAmount;
    }

    public Integer getGiftCost() {
        return giftCost;
    }

    public void setGiftCost(Integer giftCost) {
        this.giftCost = giftCost;
    }

    public Integer getDiamondCost() {
        return diamondCost;
    }

    public void setDiamondCost(Integer diamondCost) {
        this.diamondCost = diamondCost;
    }

    public Integer getHicoinCost() {
        return hicoinCost;
    }

    public void setHicoinCost(Integer hicoinCost) {
        this.hicoinCost = hicoinCost;
    }

    public Integer getProfit() {
        return profit;
    }

    public void setProfit(Integer profit) {
        this.profit = profit;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    private String getRateInfo(Integer rate, Integer base) {
        DecimalFormat dcmFormat = new DecimalFormat("0.00");
        String rateInfo = base==0 ? "0.00" : dcmFormat.format(rate * 100.0 / base);
        return rateInfo;
    }

    public JSONObject getListItem() {
        JSONObject jsonObj = new JSONObject();
        jsonObj.put("dtdate", dtdate);
        jsonObj.put("actDevNum", actDevNum);
        jsonObj.put("actUidNum", actUidNum);
        jsonObj.put("remainDay1", getRateInfo(remainDay1, actUidNum));
        jsonObj.put("remainDay3", getRateInfo(remainDay3, actUidNum));
        jsonObj.put("remainDay7", getRateInfo(remainDay7, actUidNum));
        jsonObj.put("payAmount", payAmount);
        jsonObj.put("payUidNum", payUidNum);
        jsonObj.put("payRate", getRateInfo(payUidNum, actUidNum));
        jsonObj.put("giftCost", giftCost);
        jsonObj.put("diamondCost", diamondCost);
        jsonObj.put("hicoinCost", hicoinCost);
        jsonObj.put("profit", profit);
        return jsonObj;
    }

    public static JSONObject getLegendTitle(String category) {
        String titleName = "";
        if (category.equals("loginInfo")) {
            titleName = "活跃数据";
        } else if (category.equals("remainInfo")) {
            titleName = "留存数据";
        } else if (category.equals("payInfo")) {
            titleName = "付费数据";
        } else if (category.equals("costInfo")) {
            titleName = "消耗数据";
        } else if (category.equals("profitInfo")) {
            titleName = "活跃用户贡献厅流水";
        }
        JSONObject title = new JSONObject();
        title.put("text", titleName);
        return title;
    }

    public static JSONObject getLegendList(String category) {
        List<String> legendList = new ArrayList();
        if (category.equals("loginInfo")) {
            legendList.add("设备活跃");
            legendList.add("活跃用户数");
        } else if (category.equals("remainInfo")) {
            legendList.add("次日留存率");
            legendList.add("三日留存率");
            legendList.add("七日留存率");
        } else if (category.equals("payInfo")) {
            legendList.add("充值金额/元");
            legendList.add("付费率");
        } else if (category.equals("costInfo")) {
            legendList.add("商城礼物消耗钻石数");
            legendList.add("总消耗钻石数");
        } else if (category.equals("profitInfo")) {
            legendList.add("厅流水/钻");
        }
        JSONObject legend = new JSONObject();
        legend.put("data", legendList);
        return legend;
    }

    public static String getLegendSeriesType(String legend) {
        if (legend.equals("充值金额/元")) {
            return "bar";
        } else if (legend.equals("设备活跃") || legend.equals("活跃用户数")
            || legend.equals("次日留存率") || legend.equals("三日留存率")
            || legend.equals("七日留存率") || legend.equals("付费率")
            || legend.equals("商城礼物消耗钻石数") || legend.equals("总消耗钻石数")
            || legend.equals("厅流水/钻")) {
            return "line";
        }
        return "line";
    }

    public static Integer getLegendSeriesyAxisIndex(String legend) {
        if (legend.equals("付费率")) {
            return 1;
        }
        return 0;
    }

    public String getLegendSeriesData(String legend) {
        if (legend.equals("设备活跃")) {
            return String.valueOf(actDevNum);
        }
        if (legend.equals("活跃用户数")) {
            return String.valueOf(actUidNum);
        }
        if (legend.equals("次日留存率")) {
            return getRateInfo(remainDay1, actUidNum);
        }
        if (legend.equals("三日留存率")) {
            return getRateInfo(remainDay3, actUidNum);
        }
        if (legend.equals("七日留存率")) {
            return getRateInfo(remainDay7, actUidNum);
        }
        if (legend.equals("充值金额/元")) {
            return String.valueOf(payAmount);
        }
        if (legend.equals("付费率")) {
            return getRateInfo(payUidNum, actUidNum);
        }
        if (legend.equals("商城礼物消耗钻石数")) {
            return String.valueOf(giftCost);
        }
        if (legend.equals("总消耗钻石数")) {
            return String.valueOf(diamondCost);
        }
        if (legend.equals("厅流水/钻")) {
            return String.valueOf(profit);
        }
        return "";
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", dtdate=").append(dtdate);
        sb.append(", actUidNum=").append(actUidNum);
        sb.append(", actDevNum=").append(actDevNum);
        sb.append(", remainDay1=").append(remainDay1);
        sb.append(", remainDay3=").append(remainDay3);
        sb.append(", remainDay7=").append(remainDay7);
        sb.append(", payUidNum=").append(payUidNum);
        sb.append(", payAmount=").append(payAmount);
        sb.append(", giftCost=").append(giftCost);
        sb.append(", diamondCost=").append(diamondCost);
        sb.append(", hicoinCost=").append(hicoinCost);
        sb.append(", profit=").append(profit);
        sb.append(", createTime=").append(createTime);
        sb.append(", updateTime=").append(updateTime);
        sb.append("]");
        return sb.toString();
    }
}